<?php require ROOT_PATH . 'views/layouts/header.php'; ?>

<div class="container main-content">
    <div class="profile-header">
        <h2><?php echo htmlspecialchars($profileUser['username'], ENT_QUOTES, 'UTF-8'); ?> 的主页</h2>
        <?php if (!$isOwnProfile): ?>
            <div class="follow-action">
                <?php if ($isFollowing): ?>
                    <form action="/user/unfollow/<?php echo $profileUser['id']; ?>" method="post" style="display: inline;">
                        <button type="submit" class="button-secondary">取消关注</button>
                    </form>
                <?php else: ?>
                    <form action="/user/follow/<?php echo $profileUser['id']; ?>" method="post" style="display: inline;">
                        <button type="submit">关注</button>
                    </form>
                <?php endif; ?>
            </div>
        <?php endif; ?>
    </div>

    <div class="timeline">
        <h3>发布的动态</h3>
        <?php
        if (empty($tweets)) {
            echo "<p>这位用户还没有发布任何动态。</p>";
        } else {
            foreach ($tweets as $tweet) {
                require ROOT_PATH . 'views/_tweet.php';
            }
        }
        ?>
    </div>
</div>

<?php require ROOT_PATH . 'views/layouts/footer.php'; ?>
